//
//  ZodiacHelper.swift
//  CLExtension
//
//  Created by CharlieLiao on 2018/2/8.
//  Copyright © 2018年 Charlie. All rights reserved.
//

import Foundation

@objc public class ZodiacHelper: NSObject {
    
    private static let calendar = NSCalendar(calendarIdentifier: .chinese)
    
    /// 获取农历生肖 (默认为今年的生肖)
    @objc public class func zodiac(date: Date = Date()) -> String {
        let zodiacs = ["鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪"]
        let year = calendar!.component(.year, from: date)
        let index = (year-1)%12
        return zodiacs[index]
    }
}
